#From node AS build
FROM node AS build
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /home
COPY  ./react-demo .
#RUN  chmod +x /node_modules/.bin/react-scripts;npm run build
RUN pwd;ls;npm install -g cnpm --registry=https://registry.npm.taobao.org ;cnpm install -g react-scripts ;cnpm install;cnpm run build
From nginx AS prod
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY --from=build  /home/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
